import 'package:finance_app/src/entities/currency_rate_entity.dart';

currencyRateEntityFromJson(CurrencyRateEntity data, Map<String, dynamic> json) {
	if (json['date'] != null) {
		data.date = json['date'].toString();
	}
	if (json['currency'] != null) {
		data.currency = json['currency'].toString();
	}
	if (json['default_currency'] != null) {
		data.defaultCurrency = json['default_currency'].toString();
	}
	if (json['rate'] != null) {
		data.rate = json['rate'] is String
				? num.tryParse(json['rate'])
				: json['rate'];
	}
	return data;
}

Map<String, dynamic> currencyRateEntityToJson(CurrencyRateEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['date'] = entity.date;
	data['currency'] = entity.currency;
	data['default_currency'] = entity.defaultCurrency;
	data['rate'] = entity.rate;
	return data;
}